package com.demo.var;

/**
 * @Author WaveHi
 * @Date 23/7/2021 下午 3:28
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
public class ChangVarDemo {

    public static void main(String[] args) {

        //定义两个变量num1和num2
        int num1 = 10;
        int num2 = 20;
        System.out.println("交换前" + "\nnum1 = " + num1 + "\nnum2 = " + num2);

        //声明一个临时变量
        int temp;

        //交换
        temp = num1;
        num1 = num2;
        num2 = temp;

        System.out.println("交换后\n" + "num1 = " + num1 + "\nnum2 = " + num2);


    }

}
